package servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspWriter;

import Model.Staff;

/**
 * Servlet implementation class RoleTable
 */
@WebServlet("/RoleTable")
public class RoleTable extends HttpServlet {
	private static final long serialVersionUID = 1L;
    JspWriter out;   
    /**
     * @see HttpServlet#HttpServlet()
     */
    public RoleTable() {
        super();
        // TODO Auto-generated constructor stub
    }
    
    public RoleTable(JspWriter outputStream) {
		// TODO Auto-generated constructor stub
		out = outputStream;
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		
		ArrayList<Staff> staffTable = new ArrayList<Staff>();
		staffTable = Database.StaffDB.getRoleTable();
		
		for(int i = 0; i < staffTable.size(); i++)
		{
			out.print("<tr>");
				out.print("<td>");
				out.print(staffTable.get(i).getName());
				out.print("</td>");
				
				out.print("<td>");
				out.print(staffTable.get(i).getId());
				out.print("</td>");
				
				out.print("<td>");
				out.print(staffTable.get(i).getRole());
				out.print("</td>");
			out.print("</tr>");
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
